library("plotly")
Loading required package: ggplot2
Want to understand how all the pieces fit together? Read R for Data Science: https://r4ds.had.co.nz/
Registered S3 method overwritten by 'data.table':
method from
print.data.table
Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
Attaching package: ‘plotly’
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:stats’:
filter
The following object is masked from ‘package:graphics’:
layout
library("plot3D")
library(tidyverse) # entorno tidy
Registered S3 methods overwritten by 'dbplyr':
method from
print.tbl_lazy
print.tbl_sql
── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.1 ──
✓ tibble 3.1.6 ✓ dplyr 1.0.8
✓ tidyr 1.2.0 ✓ stringr 1.4.0
✓ readr 2.1.2 ✓ forcats 0.5.1
✓ purrr 0.3.4
── Conflicts ────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::filter() masks plotly::filter(), stats::filter()
x dplyr::lag() masks stats::lag()
library(dplyr) # manejo de datos
library(GGally) # scatterplots multiples
Registered S3 method overwritten by 'GGally':
method from
+.gg ggplot2
library(rgl) # para graficos 3D
df = read.csv("chicos.csv", stringsAsFactors = F)
indices = (
! is.na(df$WEIGHT) &
! is.na(df$STATURE) &
! is.na(df$SEX) &
! is.na(df$RACE) &
! is.na(df$AGE.IN.YEARS) &
! is.na(df$AGE.IN.MONTHS) &
df$WEIGHT>0 &
df$STATURE>0 &
df$RACE != 0 &
(df$SEX == 1 | df$SEX==2)
)
dfFiltrados = df[indices,]
```r
unique(df$SEX)
<!-- rnb-source-end -->
<!-- rnb-output-begin eyJkYXRhIjoiWzFdIDIgMVxuIn0= -->
[1] 2 1
<!-- rnb-output-end -->
<!-- rnb-chunk-end -->
<!-- rnb-chunk-begin -->
<!-- rnb-source-begin eyJkYXRhIjoiYGBgclxucmFuZ2UoZGZGaWx0cmFkb3MkQUdFLklOLllFQVJTKVxuYGBgIn0= -->
```r
range(dfFiltrados$AGE.IN.YEARS)
[1] 2015 20054
View(dfFiltrados)
plot(dfFiltrados$WEIGHT/10, dfFiltrados$STATURE/10, xlab = "Peso en KG", ylab = "Altura en CM", col=dfFiltrados$SEX)
plot(dfFiltrados$AGE.IN.MONTHS/12, dfFiltrados$STATURE/10, col=dfFiltrados$SEX, xlab = "Edad (anios)", ylab = "Altura en CM",)
peso = dfFiltrados$WEIGHT/10
edad = dfFiltrados$AGE.IN.MONTHS/12
altura = dfFiltrados$STATURE/10
sexo = dfFiltrados$SEX
colores = c('blue','red')
fig <- plot_ly(x=~altura, y=~edad, z=~peso, marker = list(color = colores[dfFiltrados$SEX], showscale = F) , type="scatter3d", mode="markers", col=sexo, size = 1)
fig <- fig %>% layout(title = 'Peso en funcion de altura y edad'
)
fig
Warning: 'scatter3d' objects don't have these attributes: 'col'
Valid attributes include:
'connectgaps', 'customdata', 'customdatasrc', 'error_x', 'error_y', 'error_z', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meta', 'metasrc', 'mode', 'name', 'opacity', 'projection', 'scene', 'showlegend', 'stream', 'surfaceaxis', 'surfacecolor', 'text', 'textfont', 'textposition', 'textpositionsrc', 'textsrc', 'texttemplate', 'texttemplatesrc', 'transforms', 'type', 'uid', 'uirevision', 'visible', 'x', 'xcalendar', 'xhoverformat', 'xsrc', 'y', 'ycalendar', 'yhoverformat', 'ysrc', 'z', 'zcalendar', 'zhoverformat', 'zsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
Warning: 'scatter3d' objects don't have these attributes: 'col'
Valid attributes include:
'connectgaps', 'customdata', 'customdatasrc', 'error_x', 'error_y', 'error_z', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'legendgroup', 'legendgrouptitle', 'legendrank', 'line', 'marker', 'meta', 'metasrc', 'mode', 'name', 'opacity', 'projection', 'scene', 'showlegend', 'stream', 'surfaceaxis', 'surfacecolor', 'text', 'textfont', 'textposition', 'textpositionsrc', 'textsrc', 'texttemplate', 'texttemplatesrc', 'transforms', 'type', 'uid', 'uirevision', 'visible', 'x', 'xcalendar', 'xhoverformat', 'xsrc', 'y', 'ycalendar', 'yhoverformat', 'ysrc', 'z', 'zcalendar', 'zhoverformat', 'zsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
<<<<<<< HEAD
dfFiltrados$AGE.IN.YEARS
[1] 4219 4326 4476 3841 3460 3723 3394 3608 5580 5230 4893 13561 13736 13953 13397 13345 12539 12594 12413
[20] 13884 12868 12772 11928 12706 12767 12095 14471 13550 12145 12199 13832 12312 12917 13364 14213 13452 13523 13915
[39] 13731 14309 12950 13726 12906 13926 13657 12619 13635 13953 13038 12098 12235 12712 10134 10079 5976 6531 11723
[58] 5761 5024 8775 9109 10079 7320 6893 11197 8693 8197 7197 7676 8841 8482 7580 7361 11980 5073 6767
[77] 6802 4989 8394 8808 8838 8000 11345 9723 10473 11498 12221 10712 10542 9750 10073 10715 12975 11372 12172
[96] 11205 11024 11731 11835 11873 9695 9027 9830 10087 10657 10284 10383 11282 11060 11857 11520 5145 15605 16654
[115] 17402 17504 17920 17356 18600 16986 17347 16734 18539 17668 16254 15082 15071 16676 16517 14610 14356 15468 15526
[134] 16920 17463 15693 16158 16010 18060 17602 15761 15693 17257 18021 16202 15956 14843 14800 17254 15709 16024 20054
[153] 14917 16983 14832 14265 15205 15747 15002 18641 16180 16978 16473 17452 14345 16243 17668 16339 16643 17868 15430
[172] 4961 4356 4632 3972 2854 4180 3569 3939 6498 8482 8715 8241 8164 6224 6961 8315 8369 8745 7000
[191] 6786 6846 6205 6427 7638 5947 5750 6071 6506 7361 8704 7512 6600 6654 9621 7621 7961 7569 7838
[210] 7397 6323 8254 8282 8569 7254 5523 5980 6912 7986 8789 7131 8726 6090 7482 7227 5786 5331 6238
[229] 7441 5520 3786 4846 5057 4684 3731 3432 2852 2684 4408 5679 4605 4284 5964 3126 4441 4172 4690
[248] 4145 4430 4654 4597 4800 4443 4030 5027 4432 3668 3115 3008 4076 4194 4843 4643 4608 4153 3054
[267] 5276 4901 7539 8120 11556 17545 17235 13038 14441 14326 15657 17991 12931 7430 5402 4780 14375 14912 13863
[286] 14241 11734 3953 5531 12594 7380 7808 9512 9819 10920 10641 11901 11389 9476 9682 5690 7523 5720 6153
[305] 11890 11841 7068 6336 8517 8690 5520 5189 9008 4789 7213 13199 11323 2073 6257 3126 9906 8276 5101
[324] 14073 13854 10038 11964 2238 4504 9652 9953 10386 7610 8019 8104 11076 10657 10358 10843 10506 8608 9093
[343] 8515 6167 5947 7238 6399 7284 5841 5306 6964 6580 9241 9241 10386 10917 10720 9254 7405 9230 8156
[362] 8487 8780 9019 8969 8989 9008 8498 11931 11391 5887 6115 6246 6843 7263 7430 7863 11169 10676 10410
[381] 10364 7394 7435 9810 10254 9334 9621 5386 5975 7723 7506 12057 12936 6769 6427 8652 11232 11742 12312
[400] 11452 12572 9490 6865 5586 5410 14317 13665 13419 9873 7361 9852 13630 12526 13093 13252 11336 11224 12624
[419] 14221 12556 12594 12408 12854 11334 11347 11912 12591 11610 7613 7539 9317 10043 10742 9484 9832 10421 10219
[438] 12495 7219 6528 12471 13219 13139 11079 10610 10216 11652 9041 9210 6684 7153 10824 10610 10731 10736 5838
[457] 6139 11520 11871 10435 10997 5821 5273 7178 6441 6216 9397 9515 5446 6049 10495 10838 11167 8052 8279
[476] 12490 5645 5484 5235 5441 5438 6167 6189 5578 7547 3704 6290 4873 5432 3783 7698 8460 9257 9734
[495] 11917 6591 8010 6802 10073 11884 11945 11410 12109 6331 6882 7654 11284 11413 12054 11454 12134 11575 11232
[514] 13652 14202 13715 14608 13632 14035 13657 13575 13216 13356 12600 12523 12739 13931 13465 13687 13616 13539 14156
[533] 12164 11306 11547 11931 12093 7041 6282 9915 10473 12104 5405 11252 7539 7515 10769 6482 6304 7720 7328
[552] 7931 8695 9479 9399 11084 11150 12054 10569 10243 10742 10375 5424 5832 6545 6778 11495 10909 10646 6271
[571] 9821 11241 9479 7665 10076 11191 10260 11082 8594 11419 10317 10821 10358 7339 11854 11668 6002 5463 6167
[590] 7106 10290 10942 6939 6506 9410 10038 11375 11827 6115 9695 9358 9610 9578 9665 9745 10756 9904 8778
[609] 8854 8641 7397 7956 7704 8457 9369 10271 8824 9760 9761 9465 10071 10734 9728 9797 2597 5695 6013
[628] 4600 3767 2495 2857 3364 4734 2243 4197 4079 4079 2424 2983 2054 3487 3824 4287 3671 4895 3621
[647] 3986 2320 2465 2386 3638 3504 3008 4227 3397 3586 3290 2032 2547 2241 3468 2383 13367 13386 13942
[666] 14457 13295 13750 13304 14268 13391 12578 12498 15424 13301 13997 14745 13504 13082 13183 13509 13238 12621 13463
[685] 13265 13857 13789 13531 13856 14254 14750 14372 14268 13602 13728 13575 4838 3983 3868 5315 4747 4079 2175
[704] 3769 3550 3361 6224 5726 3257 2482 2367 2539 2849 2863 4246 2841 2857 2786 5983 5452 18126 18213
[723] 18038 17956 15742 16515 17334 14673 17616 17147 17975 17035 14534 15183 15989 15967 14816 14309 16186 14736 15994
[742] 14320 15145 15073 18265 16383 15238 14482 16487 16515 15323 15408 15194 15558 17778 18147 16753 16597 16712 16460
[761] 18073 18947 17457 16320 15419 15104 17701 17473 14756 13663 14454 13542 13975 14197 13260 12468 13750 14778 14194
[780] 12780 12435 13391 12361 12306 14000 13361 12501 13534 12336 13134 12641 7087 6789 7279 6512 6558 6813 8063
[799] 7712 6452 6323 7339 8317 7452 7934 11624 12356 11873 11134 9315 8800 8506 8534 8876 8854 8879 8720
[818] 10668 9506 10873 9860 10309 9747 6334 6632 15372 16268 14591 16945 14430 15287 15043 15545 8827 8013 7734
[837] 11241 10906 10805 7336 9263 6523 6671 6608 17367 15210 15126 17265 18383 14912 15115 14890 15276 14383 16167
[856] 14542 14454 15079 15358 16465 14969 14619 15172 15038 17224 14367 14591 17926 16156 18276 11964 11068 16221 18602
[875] 18424 18219 16865 17558 17501 16227 17309 16441 16219 19194 18189 18208 17397 16654 16556 16605 17926 16915 16778
[894] 18295 16761 17972 18273 17397 18778 18879 17882 16632 9399 11246 11172 7336 8852 11873 10860 12287 9441 8427
[913] 18098 9430 9241 9671 9408 8961 10221 17098 15863 15709 17413 17287 15673 15923 18254 16939 14723 16106 18049
[932] 17671 16652 16397 14706 14813 15926 15227 17476 14906 17399 15550 16268 14964 17476 15690 14876 16038 15358 14778
[951] 15060 16369 15671 16600 17117 18915 16564 16520 16052 15367 15032 15049 15073 15345 15660 14876 16802 15761 16035
[970] 16268 16328 14416 13772 13123 11994 12284 13032 13123 13189 12260 13243 14095 12216 13095 14164 12632 14479 12504
[989] 12399 14665 13682 12276 11810 12756 13498 10293 12109 12126 11632 10726
[ reached getOption("max.print") -- omitted 2884 entries ]
range(dfFiltrados$AGE.IN.MONTHS)
[1] 24 240
range(dfFiltrados$AGE.IN.YEARS)*12/1000
[1] 24.180 240.648
=======
table(dfFiltrados$RACE)
1 2 3 4 5
3370 426 31 6 51
>>>>>>> refs/remotes/origin/main
#Cinco niveles, WHITE = 1, BLACK = 2, ORIENTAL = 3, AMERICAN INDIAN = 4, MIXED = 5.
#Absoluta disparidad de muestreo en cuanto a raza.
table(dfFiltrados$SEX)
1 2
1972 1912
#En cuanto a sexo no
Las personas mas pesadas, desarollan piernas mas anchas para soportar su peso que alguien de su misma altura menos pesada?
Podemos identificar a las personas con enanismo? ademas de menor altura para su edad, que otras variables tienen fundamentalmente distintas?
A que edad pegan “el estiron” los hombres y cuando las mujeres? existe un momento concreto? Ademas de altura, que otras medidas cambian considerablemente? (medida de cintura en mujeres por ej, ensanchamiento de espalda hombres?)
<<<<<<< HEAD